/**
 * There are code generation
 */
package com.neusoft.lohas.modules.ivm.entity.product;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.neusoft.lohas.common.persistence.IdEntity;

/**
 * 供应商商品关系Entity
 * @author Jackie.Liu
 * @version 2014-12-30
 */
@Entity
@Table(name = "ivm_supplier_product")
@DynamicInsert
@DynamicUpdate
public class SupplierProduct extends IdEntity<SupplierProduct> {

	private static final long serialVersionUID = 1L;
	private Product product;  //商品
	private Supplier supplier;   //供应商
	private int defaultFlag;    //是否设为默认（0:否，1:是）

	public SupplierProduct() {
		super();
	}

	public SupplierProduct(String id){
		this();
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name = "product_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@NotNull(message="所属商品不能为空")
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	@ManyToOne
	@JoinColumn(name = "supplier_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@NotNull(message="对应供应商不能为空")
	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	public int getDefaultFlag() {
		return defaultFlag;
	}

	public void setDefaultFlag(int defaultFlag) {
		this.defaultFlag = defaultFlag;
	}
}


